<?php

namespace App\Listeners;

use App\Services\UserService;

class RecordUserReadLog
{
    protected $userServices;

    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct(UserService $userService)
    {
        $this->userServices = $userService;
    }

    /**
     * Handle the event.
     *
     * @param  object  $event
     * @return void
     */
    public function handle($event)
    {
        $user = $event->user;
        $chapter = $event->chapter;

        $this->userServices->recordUserReadLog($user->id, $chapter->novel_id, $chapter->id);
    }
}
